Skip to content

-Vphases takes names to mark, -Vprint is typer #17563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented May 23, 2023

-Vphases optionally takes a list of phase names to highlight in the output.

-Vprint optionally takes a list of phase names for printing, and defaults to typer.

Add plugins and fuse before listing -Vphases, to include plugins in the list. This also honors -Ystop-after, so the listing shows what will be constructed for a Run.

setting.isPresent if the user supplied the option; setting.userValue is the optional value supplied by the user.

If a setting has an empty default, an explicit argument must be supplied.

A couple of phase names are normalized to camelCase.

-Vprint loosely matches the phase name (contains), so do the same for -Vphases. (Would be nice to ignore upper/lower case.)

E.g., -Vphases:checkUnused,elimByName highlights both phases so that it's easy to find the miniphase of interest.

image

image

@som-snytt som-snytt marked this pull request as ready for review May 23, 2023 17:41
@som-snytt som-snytt force-pushed the tweak/show-phase branch 2 times, most recently from dffc44c to 84d4dd9 Compare May 12, 2024 08:26
@som-snytt som-snytt marked this pull request as draft May 12, 2024 08:27
@som-snytt som-snytt force-pushed the tweak/show-phase branch 2 times, most recently from 2fa3c7d to 6a23cad Compare May 12, 2024 15:01
@som-snytt
Copy link
Contributor Author

Checking -Vphases does not work in Run, but that is not urgent. Other settings that represent phase names could be added to settings to check.

@som-snytt som-snytt closed this Sep 15, 2024
@som-snytt som-snytt reopened this Nov 12, 2024
@som-snytt
Copy link
Contributor Author

Showing plugins with highlighting:
~/projects/dotty/bin/scalacQ -Xplugin:research.jar -Xplugin:div-zero.jar -Vphases:research,divideZero -Ystop-after:refchecks

image

@som-snytt
Copy link
Contributor Author

som-snytt commented Nov 12, 2024

The wild error:

Error:  -- [E177] Reference Error: /__w/scala3/scala3/compiler/src/dotty/tools/dotc/config/CliCommand.scala:122:19 
Error:  122 |    val compiler = Compiler()
Error:      |                   ^^^^^^^^
Error:      |Reference to constructor proxy for class Compiler in package dotty.tools.dotc
Error:      |shadows outer reference to object Compiler in package java.lang
Error:      |
Error:      |The instance needs to be created with an explicit `new`.
Error:      |
Error:      | longer explanation available when compiling with `-explain`
Error:  one error found
Error:  (scala3-compiler / Compile / compileIncremental) Compilation failed

https://github.com/scala/scala3/actions/runs/11796179302/job/32857488523?pr=17563

Edit: it was deprecated since 9 and removed in 21, stale interface for JIT.

This is where a mechanism to exclude API from compilation would really shine.

@som-snytt
Copy link
Contributor Author

Scala 2 partest supports testing plugins by taking -Xplugin:. to mean "current output directory". Not sure Scala 3 even supports loading from a dir; or how hard it would be to get vulpix to massage options; or whether Scala 3 supports multiple plugin classes in the plugin.properties.

Currently there is no automated test for -Vprint. That's also useful for stability of phase order.

@som-snytt som-snytt marked this pull request as ready for review November 12, 2024 23:45
@som-snytt som-snytt marked this pull request as draft March 22, 2025 18:58
@som-snytt
Copy link
Contributor Author

som-snytt commented Mar 22, 2025

Drafting to solve scalac -Vprint file.scala where the option consumes the arg.

In Scala 2, a PhasesSetting distinguishes tryToSet (which does not consume args) from tryToSetColon (which uses the supplied args if present).

In Scala 3, settings are just strings. Possibly, it is not too late to require PhasesSettings to have a special tag PhaseName . Not sure if anyone in Dottyland ever writes -Vprint typer or -Ystop-after refchecks. Settings with "choices" require a choice after the colon in -Xfoo:bar, and a phase setting is effectively a choice of phase names, albeit tweaked (-Vprint:typer+, and matching phase names by prefix).

Edit: resolved by requiring a "colon arg" if a multivalued (list) option has no default value.

That currently applies only to -Vprint and -Vphases, surprisingly. -Wunused imports, for example. -Wunused with no selected choice is rejected.

@som-snytt
Copy link
Contributor Author

@ckipp01 I think of you every time I return to this PR, which is two years now. So many colors!

@som-snytt som-snytt marked this pull request as ready for review March 23, 2025 06:54
@som-snytt som-snytt force-pushed the tweak/show-phase branch 2 times, most recently from ab6e1f9 to 962d37c Compare June 24, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant